// SETUP

#include endepisodegraphics_jester.txt

// HELPER FUNCTIONS	

function signanimate(sign) {
	var s = sign.show("turn");
	//s.onComplete(function() { resume(); sign.show("loop"); });
	//pause();
	while(!s.completed) {
		// do nothing
	}
	sign.show("loop");
}

function spinthewheel(sign, wheel) {
  var s = sign.show("turn");
	//s.onComplete(function() { resume(); sign.show("loop"); });
	//pause();
	while(!s.completed) {
		// do nothing
	}
	sign.hide();
	
  wheel.x = 30;
  wheel.y = -30;
  play("spinthewheel");
	var s = wheel.show("spin1");
	//s.onComplete(function() { resume(); sign.show("loop"); });
	//pause();
	while(!s.completed) {
		// do nothing
	}
	wheel.hide();
}

// ACTORS

actor("Jester", screenwidthmid + 400, 100, Col.multiplylightness(Col.RED, 1.25), LEFT, TOP, "chat_jester", "characters/misc/charicon_humanjester");
actor("Thief", 150, screenheight - 100, Col.multiplylightness(Col.GREEN, 1.25), LEFT, BOTTOM, "chat_thief", "characters/thief/charicon_thief");

// INTRO

play("music_cutscene_lesscheery");

changebackground("intro_sign");

sign.y = -screenheight;
jester.y = -screenheight;
sign.show("loop");
jester.show("idle");

Actuate.tween(sign, 2, { y: 0 }).ease(Expo.easeOut);
Actuate.tween(jester, 2, { y: 0 }).ease(Expo.easeOut);

wait(0.5);

fadein();

wait(1.5);

jester.show("talking");
actor("Jester", screenwidthmid, 100, Col.multiplylightness(Col.RED, 1.25), LEFT, TOP, "chat_jester", "characters/misc/charicon_humanjester");
speak("Jester", "What a sneaky, underhanded victory. Magnificent!");
jester.show("idle");

speak("Thief", "I’m not here for compliments. I’m here for prizes.");

jester.show("talking");
actor("Jester", screenwidthmid + 400, 100, Col.multiplylightness(Col.RED, 1.25), LEFT, TOP, "chat_jester", "characters/misc/charicon_humanjester");
speak("Jester", "Of COURSE you are.");
speak("Jester", "And that means it’s time to...");
speak("Jester", "SPIN THE WHEEL!|SPIN THE WHEEL!");
actor("Jester", screenwidthmid + 100, 100, Col.multiplylightness(Col.RED, 1.25), LEFT, TOP, "chat_jester", "characters/misc/charicon_humanjester");
speak("Jester", "If you land on a prize spot, you’ll get your|billion and a quick pathway out of th...");
jester.show("idle");

speak("Thief", "Got it. Spin.", "personality");

jester.show("talking");
actor("Jester", screenwidthmid + 100, 100, Col.multiplylightness(Col.RED, 1.25), LEFT, TOP, "chat_jester", "characters/misc/charicon_humanjester");
speak("Jester", "Wanna do a drum roll to build anticipation?");
jester.show("idle");

speak("Thief", "Just spin it!");

jester.hide();

spinthewheel(sign, wheel);

signanimate(sign);

jester.show("talking");
actor("Jester", screenwidthmid + 400, 100, Col.multiplylightness(Col.RED, 1.25), LEFT, TOP, "chat_jester", "characters/misc/charicon_humanjester");
speak("Jester", "...oh, BAD luck! Looks like you|missed out this time.");
speak("Jester", "But don’t lose hope - your time|in the Dungeons isn’t up yet!");
speak("Jester", "We’ll be back soon with|more episodes!");
jester.show("idle");

gamecompletefromcutscene();
